<template>
    <div id="wangeditorIndex">
        <editor-bar @changeContent="save" :value="news"></editor-bar>
    </div>
</template>

<script>
    // 引入子组件
    import EditorBar from '@/views/components/wangeditor/index'
    import {addNews,getNewsById} from '@/api/news'
    export default {
        name: "wangeditorIndex",
        // 注册子组件
        components:{
            EditorBar
        },
        data(){
            return{
                news: ""
            }
        },
        methods:{
            save(html){
                console.log("父组件接受内容：");
                console.log(html);
                let data = {content:html}
                addNews(data).then(response=>{
                    console.log("保存内容---》",response)
                })
            },
        },
        mounted() {
            // 去数据查  5c7082646c204aeca491e202b5151b76
            getNewsById("5c7082646c204aeca491e202b5151b76").then(response=>{
                console.log("获得新闻内容---》",response)
                if(response.code==200){
                     this.news = response.data.content;
                }
            })
        }
    }
</script>

<style scoped>

</style>
